package util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * Encrypt Passwords
 * 
 * @author MK
 * 
 */
public class PasswordFunctions {

	public static String encodeString(String inputString) {

		try {
			MessageDigest md5;
			md5 = MessageDigest.getInstance("MD5");
			md5.reset();
			md5.update(inputString.getBytes());
			byte[] result = md5.digest();

			StringBuffer hexString = new StringBuffer();
			for (int i = 0; i < result.length; i++) {
				hexString.append(Integer.toHexString(0xFF & result[i]));
			}
			return hexString.toString();
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		}
		return null;
	}
}